<%@ page contentType="text/html;charset=windows-1252"%>
<%@page import="com.cs.beneficios.common.ConnectionFactory, com.cs.beneficios.common.entity.Consultas, java.sql.ResultSet, java.sql.SQLException"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link href="<%= request.getContextPath() + "/css/bloques.css" %>" rel="stylesheet" type="text/css">
<title>Usuarios Administradores</title>
<script type="text/javascript">
function setValues(codigo, usuario) {
    var formaPadre = opener.document.frmSubprograma;
    formaPadre.admincodigo1.value = codigo ;
    formaPadre.usuario.value = usuario;
    window.close();                 
}
</script>   
</head>
<%
    String doAction = request.getParameter("doAction"); 
    String usuario = request.getParameter("usuario");
    if (usuario == null) usuario = "";
%>
<body>
    <br/>
    <p align="center" class="titulosenblanco">USUARIOS ADMINISTRADORES</p>
    <form name="frmCreateUser" method="post" action="usuariosadminsub2.jsp">
        <input type="hidden" name="doAction" value="execFind">
    <div>
    <table cellspacing="2" cellpadding="3" border="0" width="60%" align="center">
        <tr>
            <td width="15%" class="celdatabla"><strong>Usuario</strong></td>
            <td width="85%">
                <input type="text" Class="form"  name="usuario" value="<%=usuario%>" maxlength="40" size="40"/>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <input type="submit" value="Buscar" onclick="this.form.submit()"/>
            </td>
        </tr>
    </table>
    </div>
<%  if (doAction != null) { %>
    <%
        ConnectionFactory cf = new ConnectionFactory();
        Consultas consulta = new Consultas(cf);
        ResultSet rs = null;
        try {
    %>
        <%
            rs = consulta.getUsuAdmin(request.getParameter("usuario"));
            if (rs != null && rs.next()) {
        %>
    <table style="form" cellspacing="3" cellpadding="2" border="0" width="60%" align="center">
        <tr>
            <td width="10%" class="headerTable">CODIGO</td>
            <td width="65%" class="headerTable">NOMBRE</td>
            <td width="15%" class="headerTable">SELECCIONAR</td>
        </tr>
            <%  do { %>
        <tr>
            <td class="form"><%=rs.getString("usuario")%></td>
            <td class="form"><%=rs.getString("nombre")%></td>
            <td class="form"><input type="radio" name="seleccionar" onclick="setValues('<%=rs.getString("codigo")%>', '<%=rs.getString("usuario")%>')"/></td>
        </tr>
            <%  } while(rs.next()); %>
    </table>
        <%  } else { %>
    <div align="center" class="celdatabla"> No se encontraron registros.</div> 
        <%  } %>
    <%
        } catch(SQLException e) {
                e.printStackTrace();
        } finally {
            try { rs.close(); } catch (SQLException e) { e.printStackTrace(); }
            try { cf.closeConnection(consulta.getConn()); } catch (SQLException e) { e.printStackTrace(); }
        }
    %>
<%  } %>
    </form>
</body>
</html>
